package com.bolt.core.view.freemarker;

import com.bolt.common.utils.SpringContextUtil;
import com.bolt.core.view.components.ComponentsBase;
import com.bolt.core.view.components.YearSelect;
import com.bolt.support.freemarker.DirectiveUtil;
import freemarker.template.TemplateModel;

import java.util.Map;

/**
 * Created by Administrator on 2019/4/18.
 */
public class YearSelectModel extends InputModel {


    public int getEnd(Map<String, TemplateModel> params) {
        return DirectiveUtil.getInt(params, "end",2020);
    }


    public int getStart(Map<String, TemplateModel> params) {
        return DirectiveUtil.getInt(params, "start",2000);
    }

    @Override
    public ComponentsBase getUI(Map params) {
        YearSelect select = new YearSelect();
        SpringContextUtil.inject(select);
        return select;
    }

    @Override
    protected void populateParams(ComponentsBase component,Map<String, TemplateModel> params) {
        super.populateParams(component,params);
        component.addParameter("start", getStart(params));
        component.addParameter("end", getEnd(params));
    }
}

 